package com.swg;

import com.swg.bean.Person;
import com.swg.config.MainConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author 【swg】.
 * @Date 2018/5/27 20:50
 * @DESC
 * @CONTACT 317758022@qq.com
 */
public class MainTest {
    public static void main(String[] args) {
//        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
//        Person person = (Person) applicationContext.getBean("person");
//        System.out.println(person);

        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);
        Person person = applicationContext.getBean(Person.class);
        System.out.println(person);


        String[] names = applicationContext.getBeanNamesForType(Person.class);
        for(String name:names){
            System.out.println(name);
        }
    }
}
